<div class="row">
    <div class="panel panel-default">
        <div class="panel-body">
            <ul id="myTab" class="nav nav-tabs">
                <li class="active">
                <a href="#home" data-toggle="tab" style="font-weight:600;" class="_indexList">
                设备入库管理
                </a>
                </li>
                <li>
                <a href="#ios" data-toggle="tab" style="font-weight:600;" class="box-01">添加入库单</a>
                </li> 
            </ul>
    <div id="myTabContent" class="tab-content">
    <div class="tab-pane  active" id="home">
            <form action='{:U("Product/index")}' class="form-inline text-right fr m-b-5">
                名称：<input type="text" name='name' value='{$Think.get.name}' class="form-control mr20 w150" >
               <!--  分类：<select name='cid' class="form-control mr20 w150" >
               <option value='0'>全部</option>
               <volist name="classifyList" id="classifyList">
                   <option value='{$classifyList.id}' <eq name='Think.get.cid' value='$classifyList["id"]'>selected</eq>> {$classifyList.name}</option>
               </volist>
                           </select> -->
                <button class="btn btn-primary" type="submit">搜索</button>
            </form>
            <div class="table-responsive">
                <table class="table table-striped table-bordered table-hover">
                    <thead>
                        <tr>
                            <th width="60">序号</th>
                            <th>设备名称</th>
                            <th>设备型号</th>
                            <th>计量单位</th>
                            <th>单价</th>
                            <th>数量</th>
                            <th>总价格</th>
                            <th>仓库</th>
                            <th>入库时间</th>
                            <th>状态</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                     <empty name="list">
                            <tr><td colspan="11" align="center">暂无信息</td></tr>
                        </empty>
                    <volist name="list" id="list">
                        <tr>
                            <td>{$i}</td>
                            <td>{$list.name}</td>
                            <td>{$list.xinghao}</td>
                            <td>{$list.unit}</td>
                            <td>{$list.danjia}</td>
                            <td>{$list.number}</td>
                            <td>{$list.price}</td>
                            <td>{$list.cangku}</td>
                            <td>{$list.times|date="Y-m-d H:i", ###}</td>
                            <td><button class='btn <eq name="list.status" value="1">btn-primary<else />btn-default</eq> btn-sm setStatus' type="button" data-url='{:U("Product/setStatus?id=".$list["id"])}' data-status="{$list.status}"><eq name="list.status" value='1'>启用<else />禁用</eq>
                            </button>
                            </td>
                            <td>
                                <a class="btn-sm btn btn-default editText " data-id='{$list.id}'>修改</a> 
                                <a name="list.num" value="0">
                                    <button data-url='{:U("Product/del?id=".$list["id"])}' class="btn btn-default btn-sm delBtn" type="button">删除</button>
                                </a>
                            </td>
                        </tr>
                    </volist>
                    </tbody>
                </table>
            </div>
            {$page}
        </div>
    <div class="tab-pane fade" id="ios">
        <div class="row">
        <div class="panel">
          <div class="panel-body">
                <form role="form"  id="myform" method="post" class="form-horizontal">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">设备名称：<span class="c-red">*</span></label>
                        <div class="col-sm-4">
                         <select class="form-control" name="name">
                            <volist name='list_sto' id='list_sto'>
                             <option value="{$list_sto.name}" <eq name='list_sto.name' value='$info.name' > selected </eq> >{$list_sto.name}</option>
                             </volist>
                          </select>
                    </div>
                    </div>
                      <div class="form-group">
                        <label class="col-sm-3 control-label">设备型号：<span class="c-red">*</span></label>
                        <div class="col-sm-4">
                            <input class="form-control required"  name="xinghao" value="{$info.xinghao}" maxlength="100">
                        </div>
                    </div>
                     <div class="form-group">
                        <label class="col-sm-3 control-label">单位：<span class="c-red">*</span></label>
                        <div class="col-sm-4">
                            <select class="form-control" name="unit">
                                <volist name='unitList' id='unit'>
                                    <option value="{$unit}"<eq name='unitList.unit' value='$info.unit'> selected </eq> >{$unit}</option>
                                </volist>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">单价：<span class="c-red">*</span></label>
                        <div class="col-sm-4">
                            <input class="form-control required" onkeyup="jisuan();" id="text1"   name="danjia" value="{$info.danjia}" maxlength="100">
                        </div>
                    </div>
                    
                    <div class="form-group">
                        <label class="col-sm-3 control-label">数量：<span class="c-red">*</span></label>
                        <div class="col-sm-4">
                            <input class="form-control required" onkeyup="jisuan();" id="text2" name="number" value="{$info.number}" maxlength="100">
                        </div>
                    </div>
                     <div class="form-group">
                        <label class="col-sm-3 control-label">总价：<span class="c-red">*</span></label>
                        <div class="col-sm-4">
                            <input class="form-control required" onkeyup="jisuan();" id="text3" name="price" value="{$info.price}" maxlength="100">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">仓库：<span class="c-red">*</span></label>
                           <div class="col-sm-4">
                             <td><select class="form-control" name="cangku">
                                <volist name='list_cke' id='list_ck'>
                                    <option value="{$list_ck.name}" <eq name='list_ck.name' value='$info.cangku'> selected </eq> > 
                                    {$list_ck.name}</option>
                                </volist>
                                </select></td>
                        </div>
                    </div>
                     <div class="form-group">
                        <label  class="col-sm-3 control-label">状态：</label>
                        <div class="col-sm-4 input-group">
                        <label class="radio-inline">
                            <input type="radio" value="1" name="status" <neq name="info.status" value="0">checked</neq>>启用
                        </label>
                        <label class="radio-inline">
                            <input type="radio" value="0" name="status" <eq name="info.status" value="0">checked</eq>>禁用
                        </label>
                    </div>
                    </div>
                     <input type='hidden' name='id' id="id" value='{$info.id}'>
                    <div class="form-group">
                        <div class="col-sm-offset-3 col-sm-5">
                            <button class="btn btn-primary" type="submit">保存</button>
                            <a href="{:U('Product/index')}"><button class=" btn btn-default" type="button">返回</button></a>
                        </div>  
                    </div>
                </form>
            </div>
        </div>
</div>
    </div>
</div>
  <link rel="stylesheet" type="text/css" href="/Public/Common/css/jquery.searchableSelect.css">
  <script type="text/javascript" src="/Public/Common/js/jquery.searchableSelect.js"></script>
<script type="text/javascript">
function jisuan(){
            var text1=document.getElementById("text1").value; 
            var text2=document.getElementById("text2").value;    
           document.getElementById("text3").value=parseFloat(text1)*parseFloat(text2);
        }
$(function(){  
    $('.editText').click(function(){
        var id = $(this).data('id'); waiting();
        $.get('{:U("Product/edit")}', {id: id}, function(data){
            complete();
            if(data.status == 1){
                $(".box-01").html("修改入库单");
                $('#myform input[name="id"]').val(id);
                $('#myform select[name="name"]').val(data.info.name);
                $('#myform input[name="xinghao"]').val(data.info.xinghao);
                $('#myform input[name="danjia"]').val(data.info.danjia);
                $('#myform select[name="unit"]').val(data.info.unit);
                $('#myform input[name="number"]').val(data.info.number);
                $('#myform input[name="price"]').val(data.info.price);   
                $('#myform select[name="cangku"]').val(data.info.cangku); 
               $("#myform :radio[name=status][value='"+data.info.status+"']").attr("checked",true);      
                $('#myform').attr('action', '{:U("Product/edit")}');
                $(".box-01").tab('show');
                $('._indexList').bind('click',function(){
                    _act_indexList();
                });
            }else{
                showInfo(data.info);
            }
        });
    });
$('.fenlei').searchableSelect(); 
});
          
var _add = function(){
    $(".box-01").html("添加供应商");
    $('#myform')[0].reset();
}

var _act_indexList = function(){
    var msg = "确定不修改？";  
    if (confirm(msg)==true){  
        _add();
        $('._indexList').unbind('click');     
        return true;  
    }else{
        setTimeout('_pri_show()', 50);
        return false;
    }
}

var _pri_show = function(){
    $("#myTab a:eq(1)").tab('show');
    console.log($('#myTab a:eq(1)').html());
}
</script>